package org.lanqiao.tjut.control;

import javax.annotation.Resource;

import org.lanqiao.tjut.bean.UsersEntity;
import org.lanqiao.tjut.service.IUserInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class UserLoginControl {
	// 组合service层，依赖注入
	@Resource
	private IUserInfoService userService;

	@RequestMapping(value = "/login", method = RequestMethod.POST)
	public String doLogin(String userName,Model model) {
		System.out.println(userName+"正在进行登录处理。。。");
		UsersEntity userE = userService.selectUsersInfo(2);
		String strName = (userE == null ? "" : userE.getUsername());
		System.out.println("数据库查询的用户信息为：" + strName);
		model.addAttribute("loggerName", strName);
		//跳转界面，在spring-mvc.xml中已省掉前缀后缀
		return "logined";
	}
}
